<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  <title>百度地图离线API V2.1  www.xiaoguo123.com</title>
	<style type="text/css">
  body, html,#map_demo, #tab, #mapfrm {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
  #menu{height:100%;overflow-y:auto}
  td{font-size:14px}
  h4{margin:0;}
  #map_demo1,#map_demo2{height: 50%}
  </style>
  <script type="text/javascript" src="../../offlinemap/map_load.js"></script>
  <link rel="stylesheet" type="text/css" href="../../offlinemap/css/map.css"/>
  
  <!--加载鼠标绘制工具-->
  <script type="text/javascript" src="../../offlinemap/tools/DrawingManager_min.js"></script>
  <link rel="stylesheet" type="text/css" href="../../offlinemap/tools/DrawingManager_min.css"/>
  
  <!--加载检索信息窗口-->
  <script type="text/javascript" src="../../offlinemap/tools/SearchInfoWindow_min.js"></script>
  <link rel="stylesheet" type="text/css" href="../../offlinemap/tools/SearchInfoWindow_min.css"/>
  
  <script type="text/javascript" src="../jquery.js"></script>
  <script type="text/javascript" src="../layer/layer.js"></script>
</head>
<body>
<div id="result">
		<input type="button" value="获取绘制的覆盖物个数" onclick="layer.msg('共有覆盖物: '+overlays.length)"/>
		<input type="button" value="清除所有覆盖物" onclick="clearAll()"/>
	</div>
<div id="map_demo">1</div>
</body>
</html>
<script type="text/javascript">  
// 百度地图API功能
	var map = new BMap.Map("map_demo");
	var point = new BMap.Point(116.418261, 39.921984);
	map.centerAndZoom(point, 8);
	//map.enableScrollWheelZoom();                        //启用滚轮放大缩小
	
	var overlays = [];
	var overlaycomplete = function(e){
        overlays.push(e.overlay);
    };
    var styleOptions = {
        strokeColor:"red",    //边线颜色。
        fillColor:"red",      //填充颜色。当参数为空时，圆形将没有填充效果。
        strokeWeight: 3,       //边线的宽度，以像素为单位。
        strokeOpacity: 0.8,	   //边线透明度，取值范围0 - 1。
        fillOpacity: 0.6,      //填充的透明度，取值范围0 - 1。
        strokeStyle: 'solid' //边线的样式，solid或dashed。
    }
    //实例化鼠标绘制工具
    var drawingManager = new BMapLib.DrawingManager(map, {
        isOpen: false, //是否开启绘制模式
        enableDrawingTool: true, //是否显示工具栏
        drawingToolOptions: {
            anchor: BMAP_ANCHOR_TOP_RIGHT, //位置
            offset: new BMap.Size(5, 5), //偏离值
        },
        circleOptions: styleOptions, //圆的样式
        polylineOptions: styleOptions, //线的样式
        polygonOptions: styleOptions, //多边形的样式
        rectangleOptions: styleOptions //矩形的样式
    });  
	 //添加鼠标绘制工具监听事件，用于获取绘制结果
    drawingManager.addEventListener('overlaycomplete', overlaycomplete);
    function clearAll() {
		for(var i = 0; i < overlays.length; i++){
            map.removeOverlay(overlays[i]);
        }
        overlays.length = 0   
    }

</script>